home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2007 December / PCWKCD1207B.iso / Blogowanie poza sfera / Scribefire-1.4.2 / scribefire-1.4.2-fx+fl.xpi / chrome / content / upload2.js < prev    next >
Encoding:
JavaScript  |  2007-07-24  |  22.2 KB  |  508 lines

  1. /*      Upload.js
  2.  * *******************
  3.  * A pretty generic FTP uploading library.
  4.  * Used here for Images and any other file (only difference is File Picker filters and strings).
  5.  *
  6.  * Many thanks to Nickolay Ponomarev for his help.
  7.  */
  8.  
  9. var gPffTempUploadObject = [];
  10.  
  11. //ftp.protocol
  12. var gPFF_MAGIC_NUMBER = 0x804b0000;
  13. var gPFFNetErrorStrings = {
  14.    "1": "Unexpected Error",                    //unexpected
  15.    "2": "User Canceled Upload",                //usercancel
  16.   "13": "FTP Refused Upload",                  //refused
  17.   "14": "Network Timeout",                     //netTimeout
  18.   "16": "Network Appears Offline",             //netOffline
  19.   "21": "Incorrect User or Password",          //ftplogin
  20.   "22": "ftpcwd",                              //ftpcwd
  21.   "23": "ftppasv",                             //ftppasv
  22.   "24": "Incorrect Password",                  //ftppwd
  23.   "25": "ftplist",                             //ftplist
  24.   "30": "Unknown Error"                        //unknown
  25. };
  26. var gPFFCI = Components.interfaces;
  27. var gPFFCC = Components.classes;
  28. var gPFFChannel = null;
  29. var gTheErrorTimer = null;
  30.  
  31. var gTempObject = [];
  32.  
  33. var gUploadService = new Object();
  34.  
  35. gUploadService = {
  36.     serviceType: null,
  37.     //this.CR = Components.results;
  38.     
  39.     // uploads stream (nsIInputStream) to the specified location (nsIURI)
  40.     upload: function(stream, uri) {
  41.       var iosvc = gPFFCC["@mozilla.org/network/io-service;1"].getService(gPFFCI.nsIIOService);
  42.       gPFFChannel = iosvc.newChannelFromURI(uri).QueryInterface(gPFFCI.nsIUploadChannel);
  43.       gPFFChannel.setUploadStream(stream, "", -1);
  44.       gPFFChannel.asyncOpen(gPFFStreamListener, window);
  45.     },
  46.     
  47.     // returns an nsIInputStream suitable for passing to nsIUploadChannel.setUploadStream
  48.     // aFile is the nsILocalFile, whose contents should be uploaded
  49.     getUploadStreamForFile: function(aFile) {
  50.       var fstream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream);
  51.       fstream.init(aFile, 1, 0, 0);
  52.     
  53.       var bufStream = gPFFCC["@mozilla.org/network/buffered-input-stream;1"].createInstance(gPFFCI.nsIBufferedInputStream);
  54.       bufStream.init(fstream, 8192);
  55.       return bufStream;
  56.     },
  57.     
  58.     getTargetURI: function(aProtocol, aUserName, aPassword, aHost, aPath) {
  59.       var uri = gPFFCC["@mozilla.org/network/standard-url;1"].createInstance(gPFFCI.nsIURI);
  60.       //uri.spec = "ftp://"+aUserName+":"+aPassword+"@"+ftpURi;
  61.       uri.spec = aProtocol + "://" + aUserName + ":" + aPassword + "@" + aHost + "/" + aPath;
  62.       return uri;
  63.     },
  64.     
  65.     sendBinaryImage: function(theFilePath, aProtocol, aUserName, aPassword, aHost, aPath) {
  66.         var myFile = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
  67.         //myFile.initWithPath("C:\\1.txt");
  68.         //myFile.initWithPath(theFilePath);
  69.         myFile = gTempObject; //Use the picked file, not the path from the textbox.
  70.         this.upload(this.getUploadStreamForFile(myFile), this.getTargetURI(aProtocol, aUserName, aPassword, aHost, aPath));
  71.     },
  72.     
  73.     getErrorStr: function(aCode){
  74.       if(aCode == 0) return "done";
  75.       if(aCode < gPFF_MAGIC_NUMBER) return "notneterror";
  76.       aCode %= gPFF_MAGIC_NUMBER;
  77.       //LOG(this.aCode);
  78.       if(aCode in gPFFNetErrorStrings){
  79.         return gPFFNetErrorStrings[aCode];
  80.       }
  81.       return "unexpected";
  82.     },
  83.     
  84.     cancelUpload: function() {
  85.         if(gPFFChannel){
  86.             gPFFChannel.cancel(gPFF_MAGIC_NUMBER + 2);
  87.             //Set Text
  88.             var localeString = performancingUI.getLocaleString('lastuploadecanceled', []);
  89.             if(gUploadService.serviceType == "blogapi"){
  90.                 localeString = performancingUI.getLocaleString('cancelapiupload', []);
  91.             }
  92.             gUploadDialogService.setFeedbackText(localeString, true);
  93.             //
  94.         }else{
  95.             var localeString = performancingUI.getLocaleString('nouploadtocancel', []);
  96.             alert(localeString);
  97.         }
  98.     },
  99.     
  100.     onReturn: function(aCode) {
  101.         if(aCode == 0){                 // success
  102.             //setTimeout(onSuccessfulUpload, DELAY);
  103.             //alert("File succesfully uploaded");
  104.             gUploadDialogService.uploadFTPGood();
  105.         }else{ // xxx beep, perhaps?  // failure - don't close
  106.             var theError = this.getErrorStr(aCode);
  107.             //alert("Error uploading: " + theError + "\n The code: " + aCode);
  108.             gUploadDialogService.onUploadError(theError, aCode);
  109.         }
  110.     },
  111.     
  112.     //Prep Binary Data
  113.     prepBinaryToBase64Data: function(aNsiFile) {
  114.         var fileInStream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream); 
  115.         fileInStream.init(aNsiFile, 0x01, 0644, false);
  116.         var binaryInStream = Components.classes["@mozilla.org/binaryinputstream;1"] .createInstance(Components.interfaces.nsIBinaryInputStream); 
  117.         binaryInStream.setInputStream(fileInStream); 
  118.         
  119.         var theData = binaryInStream.readBytes( binaryInStream.available() );
  120.         var theBase64Data = btoa(theData);
  121.         return theBase64Data;
  122.     },
  123.     
  124.     //Do newMediaObject File Upload
  125.     //metaWeblog.newMediaObject (blogid, username, password, struct)
  126.     doMediaFileUpload: function(aNsiFile) {
  127.         var theBase64Data = this.prepBinaryToBase64Data(aNsiFile);
  128.         var theGUID = window.opener.gPerformancingUtil.prefs.getCharPref("settings.lastselected.blog");
  129.         //window.opener.
  130.         if(window.opener.gSelectedBlog != null && window.opener.gSelectedBlog != 'null'){
  131.             var theBlogXML = window.opener.gPerformancingUtil.serviceObjectXML;
  132.             var myServiceObject = window.opener.gPerformancingUtil.serviceObject;
  133.             var mimeSvc = Components.classes["@mozilla.org/mime;1"].getService(Components.interfaces.nsIMIMEService);
  134.             var theMimeType = mimeSvc.getTypeFromFile(aNsiFile);
  135.             var myResponse = myServiceObject.fileUpload(aNsiFile.leafName, theMimeType, theBase64Data);
  136.             
  137.             //Do and handle the Post Request
  138.             var theCall = new PffXmlHttpReq(theBlogXML.apiurl.toString(), "POST", myResponse, false, null, null, null);
  139.             theCall.onResult  = function(aText, aXML){
  140.                 gUploadService.onBlogApiResponse( aText, aXML, theBlogXML.url.toString() );
  141.             }
  142.             theCall.onError  = function(aText, aXML){
  143.                 var localeString = performancingUI.getLocaleString('errorcontactingserver', []);
  144.                 gUploadDialogService.onUploadError(localeString,"");
  145.             }
  146.             theCall.prepCall(); //Set up The call (open connection, etc.)
  147.             theCall.request.setRequestHeader("Content-Type", "text/xml");
  148.             theCall.makeCall(); //Make the call
  149.             theCall.request.overrideMimeType ('text/xml');
  150.         }
  151.     },
  152.     
  153.     onBlogApiResponse: function(aResponseText, aResponseXML, aBlogUrl) {
  154.         var re = /(\<\?\xml[0-9A-Za-z\D]*\?\>)/;
  155.         var newstr = aResponseText.replace(re, "");
  156.         var e4xXMLObject = new XML(newstr);
  157.         gPffTempUploadObject.push(e4xXMLObject);
  158.         
  159.         var ourParsedResponse = null; 
  160.         if (e4xXMLObject.params.param.value.length() >= 1){
  161.             ourParsedResponse = window.opener.bfXMLRPC.XMLToObject(e4xXMLObject.params.param.value.children()[0]); 
  162.         }else if (e4xXMLObject.fault.value.length() >= 1){
  163.             ourParsedResponse = window.opener.bfXMLRPC.XMLToObject(e4xXMLObject.fault.value.children()[0]); 
  164.         }
  165.         gPffTempUploadObject.push(ourParsedResponse);
  166.         if(ourParsedResponse.faultString || !ourParsedResponse.url){
  167.             //dump("\nLogin Error: " + theObject.faultString + "\n")
  168.             var localeString = "";
  169.             var localeString2 = performancingUI.getLocaleString('noImageUpload', []);
  170.             var localeString3 = performancingUI.getLocaleString('noImageUpload2', []);
  171.             if(ourParsedResponse.faultString){
  172.                 localeString = performancingUI.getLocaleString('requesterror', []) + "\n\"" + ourParsedResponse.faultString + "\"";
  173.             }
  174.             alert(localeString2+"\n\n" + localeString3+"\n\n"+localeString);
  175.             gUploadDialogService.onUploadError(ourParsedResponse.faultString,"");
  176.         }else if(ourParsedResponse.url){
  177.             //Construct the URL
  178.             var theNewURL = "";
  179.             if( /http:/.test(ourParsedResponse.url.toString()) ){
  180.                 theNewURL = ourParsedResponse.url;
  181.             }else{
  182.                 if(aBlogUrl.charAt(aBlogUrl.length -1) == "/" && ourParsedResponse.url.charAt(0) == "/"){
  183.                     theNewURL = aBlogUrl.substr(0, aBlogUrl.length -1) + ourParsedResponse.url;
  184.                 }else{
  185.                     theNewURL = aBlogUrl + ourParsedResponse.url;
  186.                 }
  187.             }
  188.             gUploadDialogService.uploadBlogAPIGood(theNewURL);
  189.         }
  190.     }
  191. }
  192.  
  193. // this object gets progress notifications
  194. var gPFFStreamListener = {
  195.   onDataAvailable: function(aChannel, aCtxt, aInStr, aSourceOffset, aCount) {},
  196.   onStartRequest: function(aChannel, aCtxt) {},
  197.   onStopRequest: function(aChannel, aCtxt, aErrCode) {
  198.     //alert("Error return: " + aErrCode);
  199.     gUploadService.onReturn(aErrCode);
  200.   }
  201. };
  202.  
  203.  
  204. //DIALOG SETTINGS, ETC.
  205.  
  206. gUploadDialogService = new Object();
  207.  
  208. var gUploadDialogService = {
  209.     onRadioClick: function(theObject, forceMe) {
  210.         var theName = "";
  211.         var isTrue = false;
  212.         if(forceMe == true){
  213.             isTrue = true
  214.         }else{
  215.             try{
  216.                 theName = theObject.id;
  217.                 isTrue = (theName == "url");
  218.             }catch(e){
  219.                 var theSelected = document.getElementById("upload-details").selectedIndex;
  220.                 if(theSelected == 0){
  221.                     isTrue = true;
  222.                 }else{
  223.                     isTrue = false;
  224.                 }
  225.             }
  226.         }
  227.             document.getElementById("upload-url-label").disabled = !isTrue;
  228.             document.getElementById("upload-url").disabled = !isTrue;
  229.             try{
  230.                 document.getElementById("upload-url-copy-button").disabled = !isTrue;
  231.             }catch(e){}
  232.             
  233.             document.getElementById("upload-ftp-uri").disabled = isTrue;
  234.             document.getElementById("upload-ftp-uri-label").disabled = isTrue;
  235.             document.getElementById("upload-ftp-uri-button").disabled = isTrue;
  236.             document.getElementById("upload-ftp-upload-button").disabled = isTrue;
  237.             document.getElementById("upload-blogapi-upload-button").disabled = isTrue;
  238.             document.getElementById("upload-ftp-upload-status-label").disabled = isTrue;
  239.             
  240.             if(isTrue){
  241.                 document.getElementById("upload-url-box").setAttribute("class", "white");
  242.                 document.getElementById("upload-ftp-box").setAttribute("class", "");
  243.                 document.getElementById("upload-url").focus();
  244.             }else{
  245.                 document.getElementById("upload-ftp-box").setAttribute("class", "white");
  246.                 document.getElementById("upload-url-box").setAttribute("class", "");
  247.             }
  248.     },
  249.     saveFtpSettings: function() {
  250.           var prefsService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  251.           var prefs = prefsService.getBranch("performancing.");// Get the "performancing." branch
  252.           var stringBundle = document.getElementById("performancingstrings");
  253.           var ftpUserName = document.getElementById("username").value;
  254.           var ftpPassword = document.getElementById("password").value;
  255.           var ftpHost = document.getElementById("host").value;
  256.           var theProtocol = document.getElementById("protocol").selectedItem.value;
  257.           try{
  258.             prefs.setCharPref('ftp.host', ftpHost );
  259.             prefs.setCharPref('ftp.username', ftpUserName );
  260.             prefs.setCharPref('ftp.path', document.getElementById("path").value );
  261.             prefs.setCharPref('ftp.url-to-path', document.getElementById("url-to-path").value );
  262.             prefs.setCharPref('ftp.protocol', theProtocol );
  263.             
  264.             if(ftpUserName != ""){
  265.                 var addedUser = gPerformancingUtil.usermanagment.storeLoginDetails(ftpUserName, ftpPassword, "-ftp-" + ftpHost);
  266.             }
  267.           }catch (e){
  268.               //var alertText = stringBundle.getString("performancing.imageupload.saveerr");
  269.               //alert(alertText + e);
  270.               //Error saving FTP details
  271.               var localeString = performancingUI.getLocaleString('errorsavingftp', [e]);
  272.               alert(localeString);
  273.           }
  274.     },
  275.     onLoad: function() {
  276.         document.getElementById("upload-url").focus();
  277.         this.loadFtpSettings();
  278.         gUploadDialogService.onRadioClick(null, false);
  279.         var theGUID = false;
  280.         try{
  281.             window.opener.gPerformancingUtil.prefs.getCharPref("settings.lastselected.blog")
  282.         }catch(e){
  283.             document.getElementById("upload-blogapi-upload-button").hidden = true;
  284.         }
  285.     },
  286.     loadFtpSettings: function() {
  287.           loadPerFormancingUtil(true);
  288.           var prefsService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
  289.           var prefs = prefsService.getBranch("performancing.");// Get the "performancing." branch
  290.           var stringBundle = document.getElementById("performancingstrings");
  291.           try{
  292.               var theUserName = prefs.getCharPref('ftp.username');
  293.               document.getElementById("username").value = theUserName;
  294.               var ftpHost = prefs.getCharPref('ftp.host');
  295.               document.getElementById("host").value = ftpHost;
  296.               
  297.               var thePassword = gPerformancingUtil.usermanagment.getPassword(theUserName, "-ftp-" + ftpHost);
  298.               document.getElementById("password").value = thePassword;
  299.               
  300.               document.getElementById("path").value = prefs.getCharPref('ftp.path');
  301.               document.getElementById("path").value = prefs.getCharPref('ftp.path');
  302.               document.getElementById("url-to-path").value = prefs.getCharPref('ftp.url-to-path');
  303.               
  304.               var theProtocol = prefs.getCharPref('ftp.protocol');
  305.               if(theProtocol == "ftp"){
  306.                   document.getElementById("protocol").selectedIndex = 0;
  307.               }else if(theProtocol == "http"){
  308.                   document.getElementById("protocol").selectedIndex = 1;
  309.               }else{
  310.                   document.getElementById("protocol").selectedIndex = 2;
  311.               }
  312.           }catch (e){
  313.               //var alertText = stringBundle.getString("performancing.imageupload.saveerr");
  314.               //alert(alertText + e);
  315.               //alert("Error saving FTP details" + e);
  316.           }
  317.     },
  318.     
  319.     filePicker: function(){
  320.         this.onFilePick(true); //False to filter only images
  321.     },
  322.     
  323.     onFilePick: function(notImage) {
  324.         var nsIFilePicker = Components.interfaces.nsIFilePicker;
  325.         var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
  326.         if(!notImage){
  327.             fp.appendFilters(nsIFilePicker.filterImages);
  328.         }
  329.         var localeString = performancingUI.getLocaleString('selectimagefile', []);
  330.         fp.init(window, localeString, nsIFilePicker.modeOpen);
  331.         var res = fp.show();
  332.         if (res == nsIFilePicker.returnOK){
  333.           var thefile = fp.file;
  334.           gTempObject = thefile;
  335.           document.getElementById("upload-ftp-uri").value = thefile.path;
  336.         }
  337.     },
  338.     
  339.     tryUpload: function() {
  340.         var host = document.getElementById("host").value;
  341.         var username = document.getElementById("username").value;
  342.         var password = document.getElementById("password").value;
  343.         var path = document.getElementById("path").value;
  344.         var url_to_path = document.getElementById("url-to-path").value;
  345.         var fileName = "";
  346.         
  347.         if(host != "" && username != "" && password != "" ){
  348.             var theFilePath = document.getElementById("upload-ftp-uri").value;
  349.             if(theFilePath != ""){
  350.                 this.deckToggle(true);
  351.                 var theFileName = gTempObject.leafName;
  352.                 var theProtocol = document.getElementById("protocol").selectedItem.value;
  353.                 gUploadService.sendBinaryImage(theFilePath, theProtocol, username, password, host, path + theFileName);
  354.             }else{
  355.                 var localeString = performancingUI.getLocaleString('selectafile', []);
  356.                 alert(localeString);
  357.             }
  358.         }else{
  359.             var localeString = performancingUI.getLocaleString('setupftp', []);
  360.             alert(localeString);
  361.             document.getElementById("tabbox").selectedIndex = 1;
  362.         }
  363.     },
  364.     
  365.     //newMediaObject Blog Api upload
  366.     tryMediaBlogUpload: function() {
  367.         if (window.opener.gPerformancingUtil.serviceObjectXML.blogapi == 'atom_blogger'){
  368.             alert("Blogger does not support uploading images via the API.");
  369.         }
  370.         else {
  371.             var theFilePath = document.getElementById("upload-ftp-uri").value;
  372.             if(theFilePath != ""){
  373.                 this.deckToggle(true);
  374.                 var theFileName = gTempObject.leafName;
  375.                 gUploadService.doMediaFileUpload(gTempObject);
  376.             }else{
  377.                 var localeString = performancingUI.getLocaleString('selectafile', []);
  378.                 alert(localeString);
  379.             }
  380.         }
  381.     },
  382.     
  383.     //On Upload Start
  384.     onUploadStarted: function() {
  385.         var localeString = performancingUI.getLocaleString('uploading', []);
  386.         document.getElementById("upload-upload-progress-text").setAttribute("value", localeString);
  387.         document.getElementById("upload-url-generated").hidden = true;
  388.         gUploadService.serviceType = "ftp";
  389.         this.tryUpload();
  390.     },
  391.     
  392.     //Start Blog API upload (newMediaObject)
  393.     onBlogApiUploadStarted: function() {
  394.         var localeString = performancingUI.getLocaleString('uploading', []);
  395.         document.getElementById("upload-upload-progress-text").setAttribute("value", localeString);
  396.         document.getElementById("upload-url-generated").hidden = true;
  397.         this.tryMediaBlogUpload();
  398.         gUploadService.serviceType = "blogapi";
  399.     },
  400.     
  401.     uploadFTPGood: function() {
  402.         var localeString = performancingUI.getLocaleString('uploadcanceled', []);
  403.         this.setFeedbackText(localeString, false);
  404.         this.deckToggle();
  405.         this.onFtpUploadDone();
  406.     },
  407.     
  408.     uploadBlogAPIGood: function(aURL) {
  409.         var localeString = performancingUI.getLocaleString('uploadcanceled', []);
  410.         this.setFeedbackText(localeString, false);
  411.         this.deckToggle();
  412.         this.onBlogPIUploadDone(aURL);
  413.     },
  414.     
  415.     //Set upload status here:
  416.     setFeedbackText: function(aText, isError) {
  417.         var theLabel = document.getElementById("upload-ftp-upload-status");
  418.         theLabel.value = aText;
  419.         if(isError){
  420.             theLabel.setAttribute("style", "color: red;");
  421.         }else{
  422.             theLabel.setAttribute("style", "color: blue;");
  423.         }
  424.     },
  425.     
  426.     //On FTP Upload success
  427.     onFtpUploadDone: function() { //gUploadDialogService.uploadFTPGood();
  428.         gUploadDialogService.onRadioClick(null, true);
  429.         document.getElementById("upload-details").selectedIndex = 0;
  430.         var url_to_path = document.getElementById("url-to-path").value;
  431.         document.getElementById("upload-url-generated").hidden = false;
  432.         document.getElementById("upload-url").value = url_to_path + gTempObject.leafName;
  433.     },
  434.     
  435.     onBlogPIUploadDone: function(aURL) { //gUploadDialogService.uploadFTPGood();
  436.         gUploadDialogService.onRadioClick(null, true);
  437.         document.getElementById("upload-details").selectedIndex = 0;
  438.         //var url_to_path = document.getElementById("url-to-path").value;
  439.         document.getElementById("upload-url-generated").hidden = false;
  440.         document.getElementById("upload-url").value = aURL;
  441.     },
  442.     
  443.     onDialogAccept: function() {
  444.           var theImageURL = document.getElementById("upload-url").value;
  445.           if(theImageURL != ""){
  446.               var theURL = window.arguments[1];
  447.               var re = window.arguments[0]; 
  448.               theURL[0] = theImageURL;
  449.               re[0] = true;
  450.               return true;
  451.           }else{
  452.             var localeString = performancingUI.getLocaleString('addurltoinsert', []);
  453.             alert(localeString);
  454.             //return false;
  455.           }
  456.           return false;
  457.     },
  458.     
  459.     setErrorTimer: function(){
  460.         gTheErrorTimer = window.setTimeout('gUploadDialogService.deckToggle()', 1000);
  461.     },
  462.     
  463.     cancelErrorTimer: function(){
  464.         window.clearTimeout(gTheErrorTimer);
  465.     },
  466.     
  467.     onUploadError: function(theError, aCode){
  468.         this.setErrorTimer();
  469.         var localeString = performancingUI.getLocaleString('uploaderror', []);
  470.         var localeString2 = performancingUI.getLocaleString('theerror', [theError]);
  471.         document.getElementById("upload-upload-progress-text").setAttribute("value", localeString);
  472.         if(localeString2.length > 30){
  473.             localeString2 = localeString2.substr(0, 30) + "...";
  474.         }
  475.         this.setFeedbackText(localeString2, true);
  476.     },
  477.     
  478.     //CopyURl to clipboard
  479.     copyURLToClipboard: function(aURL){
  480.         //gContextMenu.getService('@mozilla.org/widget/clipboardhelper;1', Components.interfaces.nsIClipboardHelper).copyString(gContextMenu.linkText())
  481.         if(document.getElementById("upload-url").value != ""){
  482.             try{
  483.                 var clipBoard = gPFFCC["@mozilla.org/widget/clipboardhelper;1"].getService(gPFFCI.nsIClipboardHelper);
  484.                 //clipBoard.copyString(aURL);
  485.                 clipBoard.copyString( document.getElementById("upload-url").value );
  486.             }catch(e){
  487.                 var localeString = performancingUI.getLocaleString('cantsaveurltoclip', []);
  488.                 alert(localeString);
  489.             }
  490.             return true;
  491.         }else{
  492.             var localeString = performancingUI.getLocaleString('noblankurl', []);
  493.             alert(localeString);
  494.             return false;
  495.         }
  496.     },
  497.     //Return from Error
  498.     deckToggle: function(notError) {
  499.         var theDeck = document.getElementById('upload-ftp-deck');
  500.         if(!notError){
  501.             theDeck.setAttribute('selectedIndex', 0);
  502.         }else{
  503.             theDeck.setAttribute('selectedIndex', 1);
  504.         }
  505.     }
  506. };
  507.  
  508.